<template>
	<view>
		<view class="cart_container" v-if="cart.length !== 0">
			<!-- 收获地址 -->
			<my_address></my_address>
			<!-- 购物车标题区域 -->
			<view class="cart_title">
				<!-- 左侧的图标 -->
				<uni-icons type="shop" size="18"></uni-icons>
				<!-- 描述文本 -->
				<text class="cart_title_text">购物车</text>
			</view>

			<!-- 购物车列表 -->
			<goods_item @radio-change="radioChangeHandler" @num-change="numberChangeHandler" :showNum='true'
				:showRadio='true' :item='item' v-for="(item, i) in cart" :key="i"></goods_item>

			<!-- 结算栏 -->
			<settle></settle>
		</view>

		<!-- 空白购物车区域 -->
		<view class="empty_cart" v-else>
			<image src="/static/cart_empty@2x.png" class="empty_img"></image>
			<text class="tip_text">空空如也~</text>
		</view>
	</view>
</template>

<script>
	import badgeMix from '@/mixins/tabbar-badge.js'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		mixins: [badgeMix],
		data() {
			return {

			}
		},
		methods: {
			...mapMutations('moduleCart', ['editCartState', 'editCartcount']),
			radioChangeHandler(data) {
				this.editCartState(data)
			},
			numberChangeHandler(data) {
				this.editCartcount(data)
				this.setBadge()
			}
		},
		computed: {
			...mapState('moduleCart', ['cart'])
		},
	}
</script>

<style lang="scss">
	.cart_container {
		background-color: white;
		padding-bottom: 50px;

		.cart_title {
			height: 80rpx;
			display: flex;
			align-items: center;
			padding-left: 12rpx;
			border-bottom: 1px solid #efefef;

			.cart_title_text {
				margin-left: 20rpx;
			}
		}
	}
	.empty_cart {
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	  padding-top: 150px;
	
	  .empty_img {
	    width: 90px;
	    height: 90px;
	  }
	
	  .tip_text {
	    font-size: 12px;
	    color: gray;
	    margin-top: 15px;
	  }
	}
</style>